﻿// -----------------------------------------------------------------------
// <copyright file="MenuUsingDelegate.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Ex04.Menus.Test
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using Ex04.Menus.Delegates;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class MenuUsingDelegate
    {
        private readonly MainMenu r_MainMenu = new MainMenu();

        public MenuUsingDelegate()
        {
            PerformTheActionDelegate actionOne = new PerformTheActionDelegate(Action1);
            PerformTheActionDelegate actionTwo = new PerformTheActionDelegate(Action2);
            PerformTheActionDelegate actionThird = new PerformTheActionDelegate(Action3);
            PerformTheActionDelegate actionFourth = new PerformTheActionDelegate(Action4);
            PerformTheActionDelegate actionFifth = new PerformTheActionDelegate(Action5);
            PerformTheActionDelegate actionSixth = new PerformTheActionDelegate(Action6);
            PerformTheActionDelegate actionSeventh = new PerformTheActionDelegate(Action7);
            PerformTheActionDelegate actionEight = new PerformTheActionDelegate(Action8);

            Action activeAction1 = new Action("The first action", Action1);
            Action activeAction2 = new Action("The second action", Action2);
            Action activeAction3 = new Action("The third action", Action3);
            Action activeAction4 = new Action("The fourth action", Action4);
            Action activeAction5 = new Action("The fifth action", Action5);
            Action activeAction6 = new Action("The sixth action", Action6);
            Action activeAction7 = new Action("The seventh action", Action7);
            Action activeAction8 = new Action("The eight action", Action8);

            SubMenu subMenu1 = new SubMenu("First subMenu delegate", r_MainMenu.NameOfMain);
            SubMenu subMenu2 = new SubMenu("Second subMenu delegate", r_MainMenu.NameOfMain);
            SubMenu subMenu3 = new SubMenu("Third subMenu delegate", r_MainMenu.NameOfMain);
            SubMenu subMenu4 = new SubMenu("Fourth subMenu delegate", r_MainMenu.NameOfMain);

            subMenu3.AddMenuItem(activeAction4);
            subMenu3.AddMenuItem(activeAction5);

            subMenu1.AddMenuItem(activeAction3);
            subMenu1.AddMenuItem(subMenu3);

            subMenu4.AddMenuItem(activeAction7);
            subMenu4.AddMenuItem(activeAction8);

            subMenu2.AddMenuItem(activeAction6);
            subMenu2.AddMenuItem(subMenu4);

            r_MainMenu.AddNewItem(subMenu1);
            r_MainMenu.AddNewItem(subMenu2);
            r_MainMenu.AddNewItem(activeAction1);
            r_MainMenu.AddNewItem(activeAction2);

            r_MainMenu.Show();
        }

        public static void Action1()
        {
            Console.WriteLine("Action 1 is DONE..... :){0}", Environment.NewLine);
            Console.ReadKey();
        }

        public static void Action2()
        {
            Console.WriteLine("Action 2 is DONE..... :){0}", Environment.NewLine);
            Console.ReadKey();
        }

        public static void Action3()
        {
            Console.WriteLine("Action 3 is DONE..... :){0}", Environment.NewLine);
            Console.ReadKey();
        }

        public static void Action4()
        {
            Console.WriteLine("Action 4 is DONE..... :){0}", Environment.NewLine);
            Console.ReadKey();
        }

        public static void Action5()
        {
            Console.WriteLine("Action 5 is DONE..... :){0}", Environment.NewLine);
            Console.ReadKey();
        }

        public static void Action6()
        {
            Console.WriteLine("Action 6 is DONE..... :){0}", Environment.NewLine);
            Console.ReadKey();
        }

        public static void Action7()
        {
            Console.WriteLine("Action 7 is DONE..... :){0}", Environment.NewLine);
            Console.ReadKey();
        }

        public static void Action8()
        {
            Console.WriteLine("Action 8 is DONE..... :){0}", Environment.NewLine);
            Console.ReadKey();
        }
    }
}
